﻿using System;
using ETModel;
using ETHotfix;
using System.Threading;
using ET.HelloWorld.Model;

namespace ET.HelloWorld.Start {
    class Program {

        private static string UserHotfixDllFilePath = "./ET.HelloWorld.Hotfix.dll";
        private static string UserHotfixPdbFilePath = "./ET.HelloWorld.Hotfix.pdb";

        private static void Main(string[] args) {
            try {

                //初始化服务管理器
                ServerManager.Init(UserHotfixDllFilePath, UserHotfixPdbFilePath);

                //初始化物理引擎库
                BulletHelper.Init();

                //加载服务器启动配置
                StartConfig startConfig = Game.Scene.AddComponent<StartConfigComponent, string, int>("./StartConfig/LocalAllServer.txt", 1).StartConfig;

                //初始化服务管理器
                AutoResetEvent loopEndEvent = new AutoResetEvent(false);

                //开始当前配置的服务消息循环
                ServerManager.StartServerLoopByConfig<NetOuterComponent>(typeof(ModelInit).Assembly, startConfig, loopEndEvent);
            } catch (Exception e) {
                Log.Error(e);

                Console.ReadKey();
            }

        }
    }
}
